package financial.sharing.center.contract.model.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import financial.sharing.center.common.base.BaseEntity;
import financial.sharing.center.common.enums.ContractStageEnum;
import financial.sharing.center.common.enums.EnableStatusEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @ClassName Contract
 * @Description TODO
 * @Author guoyuhang
 * @ @csdn https://blog.csdn.net/qq_40788718
 * @Date 2021/4/5
 * @Version 1.0
 */
@Data
@AllArgsConstructor
@ToString
@Entity
public class Contract extends BaseEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    /**合同名称*/
    private String contractName;
    /**对应业务线*/
    private Integer businessLineId;
    @Transient
    private String businessLineName;
    /**合同类型*/
    private Integer contractType;
    @Transient
    private String contractTypeName;
    /**合同方向*/
    private Integer contractDirectionValue;
    @Transient
    private String contractDirectionName;
    /**合同状态*/
    private Integer contractStageValue;
    @Transient
    private String contractStageName;
    /**开始时间*/
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date startTime;
    /**结束时间*/
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date endTime;
    /**创建时间*/
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date createTime;
    /**是否弃用 0:无 1:正常 2:弃用*/
    private Integer enableStatusValue;
    @Transient
    private ContractDetail contractDetail;

    public Contract() {

    }

    public Contract(String contractName, Integer contractTypeValue, Integer contractDirectionValue) {
        this.contractName = contractName;
        this.contractType = contractTypeValue;
        this.contractDirectionValue = contractDirectionValue;
        this.createTime = new Date();
        this.contractStageValue = ContractStageEnum.未签约.getValue();
        this.enableStatusValue = EnableStatusEnum.正常.getValue();
    }
}
